<!DOCTYPE html>
<html>
<head>
<?php $this->load->view('head'); ?>
</head>
<body>
<?php $this->load->view('header'); ?>
<div class="container-fluid main">
	<div class="row">
<?php $this->load->view('left'); ?>
		<div class="main-content col-md-10">
<?php $this->load->view('crumbs'); ?>
			<div class="panel panel-default panel-my">
				<div class="panel-heading">搜索</div>
				<div class="panel-body">
					<form class="form-inline" action="<?php echo site_url('admin/advert/index'); ?>" method="get" accept-charset="utf-8" role="form">
						<div class="form-group">
							描述：
							<input type="text" class="form-control input-sm mr5" name="descrip" value="" placeholder="描述">
						</div>
						<div class="form-group">
							广告位：
							<select class="form-control input-sm mr5" name="ckey">
								<option>全部</option>
<?php $i = 1; foreach ($advert_cates as $ckey => $name) { $i < 10 && $i = '0' . $i; ?>
								<option value="<?php echo $ckey; ?>"<?php echo Utility::if_select($get['ckey'] == $ckey); ?>><?php echo $i++; ?> <?php echo $name; ?></option>
<?php } ?>
							</select>
						</div>
						<div class="form-group">
							类型：
							<select class="form-control input-sm mr5" name="advert_type">
								<option>全部</option>
								<option value="txt"<?php echo Utility::if_select($get['advert_type'] == 'txt'); ?>>文字</option>
								<option value="img"<?php echo Utility::if_select($get['advert_type'] == 'img'); ?>>图片</option>
								<option value="code"<?php echo Utility::if_select($get['advert_type'] == 'code'); ?>>代码</option>
								<option value="flash"<?php echo Utility::if_select($get['advert_type'] == 'flash'); ?>>Flash</option>
							</select>
						</div>
						<div class="form-group">
							状态：
							<select class="form-control input-sm mr5" name="status">
								<option>全部</option>
								<option value="open"<?php echo Utility::if_select($get['status'] == 'open'); ?>>开启</option>
								<option value="close"<?php echo Utility::if_select($get['status'] == 'close'); ?>>关闭</option>
							</select>
						</div>
						<button type="submit" class="btn btn-primary btn-sm">搜索</button>
					</form>
				</div>
				<!--/.panel-body -->
			</div>
			<!--/.panel -->
			<div class="panel panel-default panel-my">
				<div class="panel-heading">
					<span class="mr10">广告管理</span>
					<a class="btn btn-success btn-xs" href="<?php echo site_url('admin/advert/add'); ?>" title="添加"><i class="glyphicon glyphicon-plus"></i> 添加</a>
				</div>
				<div class="panel-body">
					<form class="form-horizontal J-ajax-form" action="<?php echo site_url('admin/advert/index'); ?>" method="post" accept-charset="utf-8" role="form">
						<div class="table-responsive">
							<table class="table table-striped table-hover">
								<thead>
									<tr>
										<th class="text-center" width="50">删除</th>
										<th>广告描述</th>
										<th>广告位</th>
										<th width="50">类型</th>
										<th width="100">结束时间</th>
										<th width="70">排序</th>
										<th class="text-center" width="50">状态</th>
										<th>管理</th>
									</tr>
								</thead>
								<tbody>
<?php if (!$adverts) { ?>
									<tr>
										<td colspan="8">啊哦！暂时还没有数据。</td>
									</tr>
<?php } ?>
<?php foreach ($adverts as $advert) { ?>
									<tr>
										<td class="text-center"><input class="J_check" type="checkbox" name="id[]" value="<?php echo $advert['id']; ?>"></td>
										<td><?php echo $advert['descrip']; ?></td>
										<td><a href="<?php echo site_url('admin/advert/index?ckey=' . $advert['ckey']); ?>"><?php echo $advert_cates[$advert['ckey']]; ?></a></td>
										<td><a href="<?php echo site_url('admin/advert/index?advert_type=' . $advert['config']['type']); ?>"><?php echo $advert_types[$advert['config']['type']]; ?></a></td>
										<td><?php echo date('Y-m-d', $advert['etime']); ?></td>
										<td><div class="length0"><input class="form-control input-sm" type="text" name="data[<?php echo $advert['id']; ?>][vieworder]" value="<?php echo $advert['vieworder']; ?>"></div></td>
										<td class="text-center"><input type="checkbox" name="data[<?php echo $advert['id']; ?>][status]" value=""<?php echo Utility::if_check($advert['status']); ?>></td>
										<td>
											<a class="mr5" href="<?php echo site_url('admin/advert/edit?id=' . $advert['id']); ?>">编辑</a>
											<a href="<?php echo site_url('admin/advert/dodel?id=' . $advert['id']); ?>">删除</a>
										</td>
									</tr>
<?php } ?>
								</tbody>
							</table>
						</div>
						<!--/.table-responsive -->
<?php if ($adverts) { ?>
						<div class="btn-wrap">
							<button type="button" class="btn btn-primary J-ajax-submit-btn mr10">确认提交</button>
							<button type="button" class="btn btn-danger J-ajax-submit-btn mr5" data-subcheck="true" data-msg="确定要删除吗？" data-action="<?php echo site_url('admin/advert/dodel'); ?>">删除</button>
						</div>
						<div class="pages">
							<?php echo $this->pagination->create_links(); ?>
						</div>
<?php } ?>
					</form>
				</div>
				<!--/.panel-body -->
			</div>
			<!--/.panel -->
		</div>
		<!--/.main-content -->
	</div>
	<!--/.row -->
</div>
<!--/.container-fluid -->
<?php $this->load->view('footer'); ?>
</body>
</html>